using Microsoft.Phone.Controls.Maps.AutomationPeers;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
namespace Microsoft.Phone.Controls.Maps.Overlays
{
	[TemplatePart(Name = "ErrorMessage", Type = typeof(TextBlock))]
	public class LoadingErrorMessage : Overlay
	{
		internal const string ErrorMessageElementName = "ErrorMessage";
		private TextBlock container;
		private TextBlock Container
		{
			get
			{
				return this.container;
			}
			set
			{
				if (value != null)
				{
					this.SetSetContainer(value);
				}
			}
		}
		public LoadingErrorMessage()
		{
			base.set_DefaultStyleKey(typeof(LoadingErrorMessage));
			this.container = new TextBlock();
			this.container.set_TextWrapping(2);
		}
		public void SetConfigurationError(CultureInfo culture)
		{
			OverlayResources.Culture = culture;
			this.container.set_Text(string.Format(culture, OverlayResources.LoadingConfigurationErrorMessage, new object[0]));
		}
		public void SetUriSchemeError(CultureInfo culture)
		{
			OverlayResources.Culture = culture;
			this.container.set_Text(string.Format(culture, OverlayResources.LoadingUriSchemeErrorMessage, new object[0]));
		}
		public void SetCredentialsError(CultureInfo culture)
		{
			OverlayResources.Culture = culture;
			this.container.set_Text(string.Format(culture, OverlayResources.InvalidCredentialsErrorMessage, new object[0]));
		}
		private void SetSetContainer(TextBlock newContainer)
		{
			if (this.container != null)
			{
				newContainer.set_Text(this.container.get_Text());
			}
			this.container = newContainer;
		}
		protected override AutomationPeer OnCreateAutomationPeer()
		{
			return new BaseAutomationPeer(this, "LoadingErrorMessage");
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.Container = (base.GetTemplateChild("ErrorMessage") as TextBlock);
			base.FireTemplateApplied();
		}
	}
}
